<template>
  <div class="async-demo">
    <h4>异步加载的组件</h4>
    <p>这个组件是通过 defineAsyncComponent 异步加载的</p>
    <div class="demo-content">
      <p>当前时间: {{ currentTime }}</p>
      <button @click="count++">点击计数: {{ count }}</button>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'

const count = ref(0)
const currentTime = ref('')

onMounted(() => {
  currentTime.value = new Date().toLocaleString()
  console.log('异步组件已加载')
})
</script>

<style scoped>
.async-demo {
  border: 2px solid #42b883;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
  background-color: #f8f9fa;
}

.async-demo h4 {
  color: #42b883;
  margin-bottom: 8px;
}

.demo-content {
  margin-top: 12px;
}

.demo-content button {
  background-color: #42b883;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 8px;
}

.demo-content button:hover {
  background-color: #369870;
}
</style>
